package com.platform.utils;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

public class HttpContextUtils {
	
    public static final String LOGIN_USER = "LOGIN_USER";
    
    public static final String LOGIN_USER_OPEN_ID = "LOGIN_USER_OPEN_ID";

	public static HttpServletRequest getHttpServletRequest() {
		return ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
	}
	
	public static HttpSession getHttpSession() {
		return ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest().getSession();
	}
	
	public static Object getCurrentUser() {
		return HttpContextUtils.getHttpSession().getAttribute(HttpContextUtils.LOGIN_USER);
	}
}
